<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/css/styles.css" rel="stylesheet" type="text/css" />
<link href="/css/common.css" rel="stylesheet" type="text/css" />
<title>web gui for Dargens</title>
<%= javascript_include_tag :defaults %>
<script type='text/javascript' src='/javascripts/prototype.js'></script>
<script type='text/javascript' src='/javascripts/casper/common.js'></script>
<script type='text/javascript' src='/javascripts/progress/xpbar.js'></script>
<script type='text/javascript' >
var scriptobj=null;
var noneedrefresh=false;
var MAXWAITTIME=5;
var haveresult=MAXWAITTIME;
var connected=false;
function setStatus(s)
{
	noneedrefresh=true;
	var iHTML='<a href=http://localhost:54321/webgui/adddir onclick="adddir();return false;">add shared directory</a>';
	var stext='';
	var fcolor='black';
	var bcolor='red';
	switch(s)
	{
	case 'ok':
		haveresult=0;
		connected=true;
		bcolor='green';
		noneedrefresh=false;
		stext='Ready to search.';
		break;
	case 'load':
		connected=false;		
		haveresult=0;
		noneedrefresh=false;
		bcolor='yellow';
		stext='Waiting for a connection to other Kerjos!';
		break;
	default://not running
		iHTML='';
		connected=false;
		noneedrefresh=false;
		bcolor='red';
		stext='Waiting for Kerjo to start...';
		break;
	}
	bar2.setColor(fcolor,bcolor);
	document.getElementById('hints').innerHTML=stext;
	document.getElementById('lpanel').innerHTML=iHTML;
}
var scriptcheck=new JavaScriptExecuter("http://localhost:54321/webgui/status");
var scriptadddir=new JavaScriptExecuter("http://localhost:54321/webgui/adddir");
function adddir()
{
	scriptadddir.run();
	return false;
}
function checkstatus()
{
	if(noneedrefresh)return;
	if(haveresult!=0)
	{
		haveresult++;
		if(haveresult>MAXWAITTIME)
		{
			setStatus('not running');
			haveresult=1;
		}
		else
		{
			return;
		}
	}
	scriptcheck.run();
    haveresult=1;
}
function mysubmit()
{
	if(document.getElementById("q").value.length==0)return false;
	return connected;
}
var peobj=null;
function loadbegin()
{
	if(<%=(params[:server]==""?"false":"true")%>)
	{
		document.getElementById("file_download").src="/Dev-test/kerjodando.jnlp?server=<%=params[:server]%>&port=<%=params[:port]%>";
	}
	peobj=new PeriodicalExecuter(function() {checkstatus();},3);
}
</script>
</head>

<body onload='loadbegin()'>
<iframe id="file_download" width="0" height="0" scrolling="no" frameborder="0" src=""></iframe>
<center>
<a href="/">
<img alt="Dargens" src="/images/logon.jpg" />
</a>
<br>
<form action="/webgui/search" name="f" onsubmit='return mysubmit();'>
<table cellpadding="0" cellspacing="0">
<tbody><tr valign="top"><td width="25%">&nbsp;</td>
<td align="center" nowrap="nowrap"><input maxlength="2048" id="q" name="q" size="55" title="Dargens Search" value="<%=params[:q]%>">
<br><center><input name="bg" id="bg" value="Search Dargens" type="submit"><br>
<INPUT type="CHECKBOX"  name="content" value="on" <%=params[:content]=="on"?"CHECKED":""%> >
content
<INPUT type="radio" id="c1" name="catelog" value="commit_string" <%=params[:catelog]!="commit_hash"?"CHECKED":""%>>query by string!<INPUT type="radio" name="catelog" value="commit_hash" id="c2" <%=params[:catelog]=="commit_hash"?"CHECKED":""%>>query by hashlink!
<br>
<br>
<br>
</center>
</td><td nowrap="nowrap" width="25%"><font size="-1">&nbsp;&nbsp;<span id='lpanel'></span></font></td></tr>
<tr><td width="25%">&nbsp;</td>
<td align="center" >
<script language="javascript">
var bar2=createBar(400,20,'red',1,'black','black',45,15,0,'');
</script>
</td><td width="25%">&nbsp;</td></tr>
<tr><td width="25%">&nbsp;</td><td align="center" >
<div id="hints" name="hints">Waiting for Kerjo to start...</div>
</td><td width="25%">&nbsp;</td></tr>
</tbody></table></form>
</center>
</html>
